package com.corejava.training.collections.set;

import java.util.*;
import java.util.Map.*;

public class SimpleHashMap {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// create a map that contains student names and their favorite fruits
		Map<String, String> studentNameFruit = new HashMap<String, String>();
		studentNameFruit.put("henry", "apple");
		studentNameFruit.put("Reenu", "orange");
		studentNameFruit.put("Ravi", "grape");

		// use keyset to get students name from Map, then get their favorite fruits by name
		Set<String> keySet = studentNameFruit.keySet();
		for (String name : keySet) {
			System.out.println("student name: " +name);
			
			// retrieve students favorite fruits using their name
			String fruits = studentNameFruit.get(name);
			System.out.println(name + "\'s favorite fruit is " + fruits);
			System.out.println(); 
		}

		// retrieve students names and favorite fruits using entryset and keyset
		Set<Entry<String, String>> names = studentNameFruit.entrySet();
		for (Entry<String, String> entrySet : names) {
			 System.out.println("Names = " + entrySet.getKey());
			 System.out.println(entrySet.getKey() + "\'s favorite fruit = "  + entrySet.getValue());
			 
		}
				
				/*Set<Entry<String, String>> entrySet = telephoneDirectory.entrySet();
		for(Entry<String, String> eachEntry : entrySet)
		{
			System.out.println("Key = " + eachEntry.getKey());
			System.out.println("Value = " + eachEntry.getValue());
		}
		
		
		String soumithsNumber = telephoneDirectory.get("Soumith");
		System.out.println("soumithsNumber = " + soumithsNumber);
	}
*/
		
		
	}

}
